#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<cstdio>

using namespace std;

int main()
{
    int n, x, sum = 0;
    cin >> n;
    for (int j = 1; j <= n; j++)
    {
        cin >> x;
        for (int i = 1; i * i <= x; i++)
        {
            if (x % i == 0)
            {
                if (i < x)  sum += i;
                if (i != x / i && x / i < x) sum += x / i;
            }
        }
        if (sum == x)
            printf("%d is perfect\n", x);
        else
            printf("%d is not perfect\n", x);
        sum = 0;
    }
    return 0;
}
